package com.bytedance.touch.message

import android.util.Log
import com.bytedance.touch.toJson
import com.bytedance.touch.view.SimpleMotionEvent
import com.korion.channel.IChannel

class MsgHelper(channel: IChannel){

    companion object {
        const val TAG = "MsgHelper"
    }

    private val mChannel: IChannel = channel

    fun sendTouchEvent(event: SimpleMotionEvent){
        sendTouchEvents(arrayListOf(event))
    }

    fun sendTouchEvents(events: List<SimpleMotionEvent>){
        if (!mChannel.isConnect()){
            return
        }
        val json = events.toJson()
        val msg = CmdMsg(0, json).toJson()
        Log.d(TAG, "send: $msg")
        mChannel.send(msg)
    }
}